/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ceair.flight.refund.service.cronjob.autocheck.impl;

import com.ceair.flight.refund.dto.appmoblie.RefundApplyDto;
import com.ceair.flight.refund.service.cronjob.validator.IValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author information
 */
abstract class BaseValidatorChecker extends BaseAutoChecker {

    private static final Logger LOG = LoggerFactory.getLogger(BaseValidatorChecker.class);

    public BaseValidatorChecker(String checkerName) {
        super(checkerName);
    }

    abstract IValidator getValidator(final RefundApplyDto refundApply);

    protected boolean validate(final RefundApplyDto refundApply) {
        IValidator validator = getValidator(refundApply);
        if (validator == null) {
            return false;
        }
        boolean isValid = validator.validate(refundApply);
        LOG.info("Refund apply {} price is {} for auto audit.", refundApply, isValid ? "valid" : "invalid");
        return isValid;
    }
}
